{extend name="Layout/treegrid" /}
{block name="content_header"}
<h1>
    图片类别管理
    <small>advanced tables</small>
</h1>
<ol class="breadcrumb">
    <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
    <li><a href="#">内容</a></li>
    <li class="active">图片类别管理</li>
</ol>
{/block}
{block name="content"}
<div class="box">
    <div class="box-header">
        <div class="row">
            <div class="col-md-5">
                <button type="button" class="btn btn-default navbar-btn xsui-btn-add-dialog" data-url="{:url('edit')}" title="新增图片类别">新增</button>
                <button type="button" class="btn btn-danger navbar-btn xsui-btn-multi-delete" data-url="{:url('delete','id=varkey')}">批量删除</button>
                <button type="button" class="btn btn-warning navbar-btn xsui-btn-process" title="同步图片表的类别名称" data-url="{:url('synchronous')}">同步</button>
                <button type="button" class="btn btn-success navbar-btn xsui-btn-refresh">刷新</button>
            </div>
            <div class="col-md-7">
                <form class="navbar-form navbar-right">
                    <div class="form-group">
                        <input type="text" name="word" class="form-control" placeholder="关键词..." title="名称、代码" value="{$search.word}" />
                    </div>
                    <button type="submit" class="btn btn-default">搜索</button>
                </form>
            </div>
        </div>
    </div>
    <!-- /.box-header -->
    <div class="box-body">
        <table class="xsui-treegrid table table-condensed table-bordered table-striped table-hover">
            <thead>
                <tr>
                    <th><input type="checkbox" class="xsui-btn-checking-all" /></th>
                    <th>#</th>
                    <th>名称</th>
                    <th>代码</th>
                    <th>排序</th>
                    <th>状态</th>
                    <th>创建时间</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                {foreach name="tree" item="vo"}
                <tr class="treegrid-1" data-key="{$vo.id}">
                    <td><input type="checkbox" value="{$vo.id}" /></td>
                    <td title="{$vo.id}"></td>
                    <td title="{$vo.id}|{$vo.title}"><a href="{:url('edit','id='.$vo['id'])}" class="xsui-btn-edit-dialog" data-id="{$vo.id}" title="编辑 {$vo.title}">{:xsfn_msubstr($vo['title'],0,30)}</a></td>
                    <td>{$vo.code}</td>
                    <td class="xsui-cell-sort"><input type="text" value="{$vo.sort}" size="3" data-value="{$vo.sort}" data-url="{:url('changeSort','id='.$vo['id'].'&sort=varsort')}" title="更改后,鼠标点击页面任意位置即可自动生效" /></td>
                    <td class="xsui-cell-status"><a href="{:url('changeStatus','id='.$vo['id'].'&status=varstatus')}" data-value="{$vo.status}" title="点击隐藏" class="text-success"><i class="fa fa-check fa-fw"></i></a></td>
                    <td>{$vo.create_time}</td>
                    <td class="xsui-action-td">
                        <div class="btn-group">
                            <a class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" href="#">
                                操作
                                <span class="caret"></span>
                            </a>
                            <ul class="dropdown-menu pull-right" style="min-width: 60px">
                                <li><a href="{:url('edit','pid='.$vo['id'])}" class="xsui-btn-edit-dialog" title="新增子图片类别 - {$vo.title}"><i class="glyphicon glyphicon-plus"></i>添加</a></li>
                                <li><a href="{:url('edit','id='.$vo['id'])}" class="xsui-btn-edit-dialog" title="编辑 {$vo['title']}"><span class="glyphicon glyphicon-edit"></span>编辑</a></li>
                                <li><a href="{:url('delete','id='.$vo['id'])}" class="xsui-btn-delete" title="删除 {$vo['title']}"><span class="glyphicon glyphicon-remove"></span>删除</a></li>
                            </ul>
                        </div>
                    </td>
                </tr>
                {foreach name="vo['children']" item="vo2"}
                <tr class="treegrid-2  treegrid-parent-1" data-key="{$vo2.id}">
                    <td><input type="checkbox" value="{$vo2.id}" /></td>
                    <td title="{$vo2.id}"></td>
                    <td title="{$vo2.id}|{$vo2.title}"><a href="{:url('edit','id='.$vo2['id'])}" class="xsui-btn-edit-dialog" data-id="{$vo2.id}" title="编辑 {$vo2.title}">{:xsfn_msubstr($vo2['title'],0,30)}</a></td>
                    <td>{$vo2.code}</td>
                    <td class="xsui-cell-sort"><input type="text" value="{$vo2.sort}" size="3" data-value="{$vo2.sort}" data-url="{:url('changeSort','id='.$vo2['id'].'&sort=varsort')}" title="更改后,鼠标点击页面任意位置即可自动生效" /></td>
                    <td class="xsui-cell-status"><a href="{:url('changeStatus','id='.$vo2['id'].'&status=varstatus')}" data-value="{$vo2.status}" title="点击隐藏" class="xsui-success"><i class="fa fa-check fa-fw"></i></a></td>
                    <td>{$vo2.create_time}</td>
                    <td class="xsui-action-td">
                        <div class="btn-group">
                            <a class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" href="#">
                                操作
                                <span class="caret"></span>
                            </a>
                            <ul class="dropdown-menu pull-right" style="min-width: 60px">
                                <li><a href="{:url('edit','pid='.$vo2['id'])}" class="xsui-btn-edit-dialog" title="新增子图片类别 - {$vo2.title}"><i class="glyphicon glyphicon-plus"></i>添加</a></li>
                                <li><a href="{:url('edit','id='.$vo2['id'])}" class="xsui-btn-edit-dialog" title="编辑 {$vo2['title']}"><span class="glyphicon glyphicon-edit"></span>编辑</a></li>
                                <li><a href="{:url('delete','id='.$vo2['id'])}" class="xsui-btn-delete" title="删除 {$vo2['title']}"><span class="glyphicon glyphicon-remove"></span>删除</a></li>
                            </ul>
                        </div>
                    </td>
                </tr>
                {foreach name="vo2['children']" item="vo3"}
                <tr class="treegrid-3  treegrid-parent-2" data-key="{$vo3.id}">
                    <td><input type="checkbox" value="{$vo3.id}" /></td>
                    <td title="{$vo3.id}"></td>
                    <td title="{$vo3.id}|{$vo3.title}"><a href="{:url('edit','id='.$vo3['id'])}" class="xsui-btn-edit-dialog" data-id="{$vo3.id}" title="编辑 {$vo3.title}">{:xsfn_msubstr($vo3['title'],0,30)}</a></td>
                    <td>{$vo3.code}</td>
                    <td class="xsui-cell-sort"><input type="text" value="{$vo3.sort}" size="3" data-value="{$vo3.sort}" data-url="{:url('changeSort','id='.$vo3['id'].'&sort=varsort')}" title="更改后,鼠标点击页面任意位置即可自动生效" /></td>
                    <td class="xsui-cell-status"><a href="{:url('changeStatus','id='.$vo3['id'].'&status=varstatus')}" data-value="{$vo3.status}" title="点击隐藏" class="xsui-success"><i class="fa fa-check fa-fw"></i></a></td>
                    <td>{$vo3.create_time}</td>
                    <td class="xsui-action-td">
                        <div class="btn-group">
                            <a class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" href="#">
                                操作
                                <span class="caret"></span>
                            </a>
                            <ul class="dropdown-menu pull-right" style="min-width: 60px">
                                <li><a href="{:url('edit','pid='.$vo3['id'])}" class="xsui-btn-edit-dialog" title="新增子图片类别 - {$vo3.title}"><i class="glyphicon glyphicon-plus"></i>添加</a></li>
                                <li><a href="{:url('edit','id='.$vo3['id'])}" class="xsui-btn-edit-dialog" title="编辑 {$vo3['title']}"><span class="glyphicon glyphicon-edit"></span>编辑</a></li>
                                <li><a href="{:url('delete','id='.$vo3['id'])}" class="xsui-btn-delete" title="删除 {$vo3['title']}"><span class="glyphicon glyphicon-remove"></span>删除</a></li>
                            </ul>
                        </div>
                    </td>
                </tr>
                {/foreach}
                {/foreach}
                {/foreach}
            </tbody>
        </table>
    </div>
    <!-- /.box-body -->
</div>
<!-- /.box -->
{/block}
{block name="script_before"}
<script>
    // 2017-3-18
    $('.xsui-btn-process').click(function(){
        $.get($(this).data('url'),function(){
            alert('同步成功!');
        })
        return false;
    })
</script>
{/block}